<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    /*
    除了0和NaN以外的其他数字
    转化为boolean类型都是true
    */
    var num = 0;
    console.log(!!num);//0转换为布尔结果是false
    var notnum = NaN;
    console.log(!!notnum);//NaN转换为布尔结果是false
    var num1 = 123;
    var num2 = -1;
    console.log(!!num1, !!num2)         //true,true
    console.log(!!undefined, !!null);   //false,false

    var str = "";           //""空字符是false 
    var spacestr = " ";     //除了""字符以外的字符串都是true
    var str1 = "hello";     //true
    console.log(!!str, !!spacestr, !!str1);



    var str2 = "hello js";
    var b1 = boolean(str2);
    /*
        转换；类型的方式：隐式转换，显式转换
        不同类型转换时，结果不同 
    */
</script>
</html>